package com.aynu.test;

import java.util.Arrays;

/**
 * @author mj
 * @version 1.0
 * @date 2020/12/23 10:36
 */
public class Solution {
    public static void main(String[] args) {
        int [] arr = {101, 34, 119, 1, -1, 90, 123};
        int[] ints = new Solution().mySort(arr);
        System.out.println(Arrays.toString(ints));
    }

    //选择排序
    public int[] mySort(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            int minIndex = i;
            int min = arr[i];
            for (int j = i + 1; j < arr.length; j++) {
                if (min > arr[j]) {
                    min = arr[j];
                    minIndex = j;
                }
            }

            if (minIndex != i) {
                arr[minIndex] = arr[i];
                arr[i] = min;
            }
        }

        return arr;
    }
}
